package com.videoshare.user.dao;

import com.sapientia.rdfmodel.RDFDataSource;
import com.sapientia.user.bean.User;
import javax.sql.*;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.framework.Test;
import java.sql.Connection;
import java.util.*;


public class UserDAOImplTest extends TestCase {
	Connection conn = null;
	UserDAOImpl dao = null;
	
	public UserDAOImplTest(String testName)
	{
		super(testName);
	}
	
	public static Test suite() 
	{
		TestSuite suite = new TestSuite("Test for sapientiatv");
		suite.addTest(new UserDAOImplTest("testGetRegisteredUsers"));
		return suite;
	}

	protected void setUp() throws Exception {
		
		super.setUp();
		javax.sql.DataSource datasource = new MyBasicDataSource().setupDataSource();
		conn = datasource.getConnection();
		dao = new UserDAOImpl(conn);
		
	}

	protected void tearDown() throws Exception {
		
		conn.close();
		super.tearDown();
		
	}

	/*
	 * Test method for 'com.sapientia.user.dao.UserDAOImpl.getUser(String)'
	 */
	public void testGetUser() {

		List users = dao.getUser("utente@inincomm.com");
		Iterator i = users.iterator();
		while( i.hasNext())
		{
			User bean = (User) i.next();
		
			System.out.println("nome: " + bean.getFirstName());
		}
	}
	
	public void testUpdateUserRegistered (){
		
		int row = dao.updateUserRegistered("utente@inincomm.com", 0);
		
		System.out.println("registered: " + row);
		
	}
	
	public void testGetRegisteredUsers () {
		
		List users = dao.getRegisteredUsers(false);
		Iterator i = users.iterator();
		while( i.hasNext())
		{
			User bean = (User) i.next();
		
			System.out.println("nome: " + bean.getFirstName());
		}
		
	}
	
}


